# -*- coding : utf_8 -*-
"""
=======================================
Time : 2025/4/13 18:40
Author : 田霄汉
Email : 522989570@qq.com
File : combat_class13.py
Project : pandas_demo
Function : VLOOKUP
=======================================
"""

import pandas as pd
import matplotlib.pyplot as plt
from config.setting import file_path

combat13_path = file_path['excel_path']+'/combat13.xlsx'
names = pd.read_excel(io=combat13_path,
                      sheet_name='name',
                      skiprows=3,
                      usecols='C:D',
                      index_col='id')
scores = pd.read_excel(io=combat13_path,
                       sheet_name='score',
                       skiprows=3,
                       usecols='C:D',
                       index_col='id')
# # 类似数据库里面的left join...on 'id'，fillna(0)是把NaN自动填充成0，如果不使用参数on会报错
# student_score = names.merge(scores, how='left', on='id').fillna(0)
# 或者使用join也可以，而且不用on也不会报错。
student_score = names.join(scores, how='left').fillna(0)
# 将score列由float转换成int
student_score.score = student_score.score.astype(int)
print(student_score)
